package com.situ.web.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.situ.web.pojo.vo.BanjiCountVO;
import com.situ.web.service.IBanjiService;
import com.situ.web.service.impl.BanjiServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/echarts")
public class EChartsServlet extends HttpServlet {
    private IBanjiService banjiService = new BanjiServiceImpl();

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("EChartsServlet.service");

        List<BanjiCountVO> list = banjiService.selectBanjiCount();
        resp.setContentType("text/html;charset=utf-8");
        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.writeValue(resp.getWriter(), list);

    }
}
